package cn.edu.lsu.integratedsurvey.bean.vo;

import cn.edu.lsu.integratedsurvey.bean.User;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 管理员信息返回VO对象
 *
 * @author Jasmine-drs
 * @date 2024/5/1 15:52
 */

@Data
public class UserInfoVo {
	@ApiModelProperty("id索引")
	private Integer id;
	@ApiModelProperty("姓名")
	private String name;
	@ApiModelProperty("账号")
	private String account;
	@ApiModelProperty("角色")
	private Integer role;
	@ApiModelProperty("部门")
	private String department;
	@ApiModelProperty("操作员id")
	private Integer operatorId;
//	@ApiModelProperty("操作员姓名")
//	private String operatorName;
	@ApiModelProperty("创建时间")
	private LocalDateTime createTime;
	@ApiModelProperty("更新时间")
	private LocalDateTime updateTime;

	/**
	 * 将User对象转换为UserInfoVo对象，注意该方法只转换部分字段，其中部门名称字段需要手动设置
	 *
	 * @param user 完整的User对象
	 * @return 前端需要的UserInfoVo对象
	 */
	public static UserInfoVo convertToVO(User user) {
		UserInfoVo userInfoVo = new UserInfoVo();
		userInfoVo.setId(user.getId());
		userInfoVo.setName(user.getName());
		userInfoVo.setAccount(user.getAccount());
		userInfoVo.setRole(user.getRole());
		userInfoVo.setDepartment(user.getDepartment());
		userInfoVo.setOperatorId(user.getOperatorId());
		userInfoVo.setCreateTime(user.getCreateTime());
		userInfoVo.setUpdateTime(user.getUpdateTime());
		return userInfoVo;
	}
}
